'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    // 新增字段
    await Promise.all([
      queryInterface.addColumn('ThirdPartyApps', 'gteVersion', Sequelize.STRING),
      queryInterface.addColumn('ThirdPartyApps', 'lteVersion', Sequelize.STRING)
    ])
    // 将旧字段forWalletVersion的值赋予新字段gteVersion中
    await queryInterface.sequelize.query(`UPDATE ThirdPartyApps SET gteVersion = forWalletVersion `)
    // 数据更新完成后删除废弃字段
    return queryInterface.removeColumn('ThirdPartyApps', 'forWalletVersion')
  },

  down: (queryInterface, Sequelize) => {
    //
  }
};
